package model;

import java.util.Stack;


public class InorderTraversal {

	private Stack<NamedTreeNode> nodePath;
	
	private NamedTreeNode root;

	/**
	 * 
	 * @param root
	 */
	public InorderTraversal(NamedTreeNode root){
		// INORDER
		this.root = root;
		nodePath = new Stack<NamedTreeNode>();
	}
	
	/**
	 * 
	 * @param root
	 */
	public void traverse() {
		NamedTreeNode current = this.root;
		
		while( current != null || !nodePath.isEmpty() ){
			if ( current != null){
				nodePath.push(current);
				current = (NamedTreeNode) current.getChildAt(NamedTreeNode.LEFT);
			}else{
				current = this.nodePath.pop();
				System.out.println(current.toString());
				current = (NamedTreeNode) current.getChildAt(NamedTreeNode.RIGHT);
			}
		}
	}	
	

	
	
	
}
